<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // 1.获取位置,大概率被系统拦截了
    /*    navigator.geolocation.getCurrentPosition(position => {
            console.log(position)
            console.log(position.timeStamp)
            console.log(position.coords)
        })*/


    // 2.检测是否联网了  联网检测
    const connectionStateChange = () => console.log(navigator.onLine);
    window.addEventListener('online', connectionStateChange);
    window.addEventListener('offline', connectionStateChange);

    // 3. navigator的其他属性
    console.log("navigator",navigator)
    
    // 4. 电池检测
    navigator.getBattery().then(battery =>{
        console.log('battery',battery);
        battery.onchargingchange = () =>{
            const {charging} = battery
            // 如果正在充电
            if(charging){
                console.log('充电中...')
            }else {
                console.log('拔了电源')
            }
        }
    })
    
    // 5.硬件检测
    console.log('处理器线程数',navigator.hardwareConcurrency)
    console.log('设备内存大小',navigator.deviceMemory)
    console.log('最大触电数',navigator.maxTouchPoints)
    
    
</script>
</body>
</html>